<template>
	<view class="main">

		<view class="form">

			<!-- 		<view class="nav">
				<navigator url="../forget/forget">找回密码</navigator>
			</view> -->
			<view class="title">
				<image src="../../../static/images/logo.png" mode=""></image>
			</view>
			<view class="list">
				<image src="../../../static/images/phone.png" mode="aspectFit"></image><input type="text"
					v-model="phone" placeholder="请输入您的账号">
			</view>
			<view class="list">
				<image src="../../../static/images/pwd.png" mode="aspectFit"></image></i><input type="password"
					v-model="pwd" placeholder="请输入密码">
			</view>
			<view class="btn" @click="handlogin">
				登录
			</view>
		</view>
		<view class="bottom">
			<view class="bottom_l" @click="changed">
				<image :src="!checke?'../../../static/images/e.png':'../../../static/images/ed.png'" mode="">
				</image>
			</view>
			<view class="bottom_r">
				我已阅读并同意<text @click="gotxt()">《隐私政策》</text>
			</view>
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				phone: '',
				pwd: '',
				checke: false,
			};
		},
		methods: {
			changed() {
				this.checke = !this.checke
			},
			gotxt() {
				uni.navigateTo({
					url: '../../users/policy/policy'
				})
			},
			handlogin() {
				if (this.checke) {
					if (this.phone == '' || this.pwd == '') {
						uni.showToast({
							title: '账号密码不能为空',
							icon: "none",
							mask: true,
							duration: 1000
						})
					} else {
						global.$http.request({
							url: '/api/Login/login',
							data: {
								phone: this.phone,
								pwd: this.pwd,
							}
						}).then(res => {
							console.log(res);
							// console.log(res.data.data.msg);
							if (res.data.code == 200) {
								uni.setStorageSync('token', res.data.data.token);
								uni.setStorageSync('userinfo', res.data.data);
								uni.showToast({
									title: res.data.msg,
									icon: "none",
									mask: true,
									duration: 1000
								})
								setTimeout(function() {
									uni.switchTab({
										url: '../../pending/pending'
									})
								}, 1000)
							}
						})
					}
				} else {
					uni.showToast({
						title: '请勾选我已阅读并同意《隐私政策》',
						icon: "none",
						mask: true,
						duration: 1000
					})
				}

			}
		}
	}
</script>

<style lang="scss">
	page {
		font-family: PingFang SC;
		background: #FFFFFF;

		.main {
			width: 750rpx;
			height: 100%;
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: space-between;

			.form {
				width: 750rpx;
				// margin-top: 40%;
				display: flex;
				flex-direction: column;
				align-items: center;


				.list {
					width: 550rpx;
					// height: 110rpx;
					display: flex;
					align-items: center;
					padding: 64rpx 20rpx 31rpx 0;
					border-bottom: 2rpx solid #808080;
					font-size: 30rpx;
					font-family: PingFang SC;
					font-weight: 400;
					line-height: 40px;

					image {
						margin: 0 29rpx 0 13rpx;
						width: 25rpx;
						height: 36rpx;
					}

					input {
						width: 100%;
					}
				}

				.title {
					margin: 246rpx 0 117rpx 0;

					image {
						width: 342rpx;
						height: 162rpx;
						;
					}
				}

				.nav {
					width: 400rpx;
					margin-top: 20rpx;
					display: flex;
					flex-direction: row-reverse;
					font-size: 26rpx;
					color: #808080;
				}

				.btn {
					width: 630rpx;
					padding: 34rpx 0;
					background: #DF3D3D;
					border-radius: 49rpx;
					font-size: 32rpx;
					color: #fff;
					display: flex;
					align-items: center;
					justify-content: center;
					margin-top: 228rpx;
				}
			}
		}

		.bottom {
			width: 620rpx;

			margin: 40rpx auto;
			display: flex;
			align-items: center;

			.bottom_l {
				image {
					width: 30rpx;
					height: 30rpx;
				}
			}

			.bottom_r {
				margin-left: 27rpx;
				font-size: 24rpx;
				font-family: Source Han Sans CN;
				font-weight: 400;
				color: #808080;

				text {
					color: #1863FF;
				}
			}
		}
	}
</style>
